<?
include("inc_security.php");

$record_id	= getValue("record_id");
$redirect	= getValue("redirect", "str", "GET", base64_encode("listing.php"));
$redirect	= base64_decode($redirect);
$db_check	= new db_query("SELECT " . $id_field . " FROM " . $gs_table . " WHERE " . $id_field . " = " . $record_id . " AND lang_id = " . $lang_id);
if($check = mysql_fetch_array($db_check->result)){
	
	//Lấy danh sách menu cần xóa
	$list_id		= "";
	$classMenu	= new menu();
	$listAll		= $classMenu->getAllChild("menus", "mnu_id", "mnu_parent_id", $record_id, "1", "mnu_id,mnu_name,mnu_type", "mnu_order ASC,mnu_name ASC", "mnu_has_child", 0);
	unset($classMenu);
	for($i=0; $i<count($listAll); $i++){
		$list_id	.= $listAll[$i]["mnu_id"] . ",";
	}
	$list_id	.= $record_id;
	
	//Xóa hết các menu + menu con
	$db_delete = new db_execute("DELETE FROM menus WHERE mnu_id IN (" . $list_id . ")");
	unset($db_delete);
	
}
unset($db_check);
redirect($redirect);
?>